<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <form name="addItem" method="post" lay-filter="component-form-group" class="layui-form">
          <input type="hidden" value="<!--{$datainfo.id}-->" name="id">
          <input type="hidden" value="<!--{$datainfo.aid}-->" name="aid">
          <input type="hidden" value="<!--{$datainfo.relate}-->" name="relate">
            
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.name}--></label>
              <div class="layui-input-block">
                <input type="text" name="title" class="layui-input" lay-verify="title" value="<!--{$datainfo.title}-->" >
              </div>
            </div>
            <div class="layui-inline">
                  <label class="layui-form-label"><!--{$lang.page.public.select}--></label>
                  <div class="layui-input-block">
                      <select name="proid" lay-verify="proid" lay-filter="brickType">
                         <option value="0"><!--{$lang.page.public.select}--></option>
                         <!--{foreach from=$pro item=item}-->
                         <option data-proname="<!--{$item.title}-->" value="<!--{$item.id}-->" <!--{if $datainfo.proid eq $item.id}-->selected<!--{/if}-->><!--{$item.title}--></option>
                         <!--{/foreach}-->
                      </select>
                  </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.public.fixed}--> <!--{$lang.page.table.money}--></label>
              <div class="layui-input-block">
                <input type="text" name="fixmoney" class="layui-input" lay-verify="fixmoney" value="<!--{$datainfo.fixmoney}-->" >
              </div>
            </div>
            <div class="layui-inline" <!--{if $datainfo.timetype eq 1 }-->style="display: none"<!--{/if}-->>
              <label class="layui-form-label"><!--{$lang.page.public.fixed}--> <!--{$lang.page.table.time}--></label>
              <div class="layui-input-block">
                <input type="text" name="fixtime" class="layui-input" lay-verify="fixtime" value="<!--{$datainfo.fixtime}-->" >
              </div>
            </div>
            <!--{if $grade eq superadmin}-->
            <div class="layui-inline">
            <label class="layui-form-label"><!--{$lang.page.public.gorun}--></label>
            <div class="layui-input-block">
              <input type="radio" name="auto" lay-filter="brickType" value="1" title="<!--{$lang.page.table.auto}-->" <!--{if $datainfo.auto eq 1}--> checked<!--{/if}-->  >&nbsp;&nbsp;<input type="radio" name="auto" lay-filter="brickType" value="2" title="<!--{$lang.page.table.noauto}-->" <!--{if $datainfo.auto eq 2}--> checked<!--{/if}-->>
            </div>
            </div>
            <!--{else}-->
                <input type="hidden" name="auto" class="layui-input" value="<!--{$datainfo.auto}-->" >
            <!--{/if}-->
          </div>

          <div class="layui-form-item">
            <!--{if $grade eq superadmin}-->
            <div class="layui-inline">
                <label class="layui-form-label"><!--{$lang.page.table.agent}--></label>
                <div class="layui-input-inline">
                  <input type="text" name="username" class="layui-input" value="<!--{$datainfo.username}-->" >
                </div>
                <button class="layui-btn" id="checkuser" type="button"><!--{$lang.page.public.select}--> <!--{$lang.page.table.agent}--></button>
            </div>
            <!--{else}-->
                <input type="hidden" name="username" class="layui-input" value="<!--{$datainfo.username}-->" >
            <!--{/if}-->

            <div class="layui-inline yunying" <!--{if $datainfo.auto eq 2}-->style="display: none;"<!--{/if}-->>
                <label class="layui-form-label"><!--{$lang.page.table.regula}--></label>
                <div class="layui-input-inline">
                  <input type="text" name="relatename" class="layui-input" value="<!--{$datainfo.relatename}-->" >
                </div>
                <button class="layui-btn" id="checkoper" type="button"><!--{$lang.page.public.select}--> <!--{$lang.page.table.regula}--></button>
            </div>
          </div>

            <div class="layui-form-item">
              <label class="layui-form-label"><!--{$lang.page.table.notes}--></label>
              <div class="layui-input-block" style="width:80%;">
                <textarea  id="demo" name="description" lay-verify="description" placeholder="<!--{$lang.page.public.pinput}-->" class="layui-textarea"><!--{$datainfo.description}--></textarea>
              </div>
            </div>

            <div class="layui-form-item">
            <label class="layui-form-label"><!--{$lang.page.table.status}--></label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="0" title="<!--{$lang.page.table.unpublish}-->" <!--{if $datainfo.status eq 0}--> checked<!--{/if}-->  >&nbsp;&nbsp;<input type="radio" name="status" value="1" title="<!--{$lang.page.table.publish}-->" <!--{if $datainfo.status eq 1}--> checked<!--{/if}-->>&nbsp;&nbsp;<input type="radio" name="status" value="2" title="<!--{$lang.page.table.finish}-->" <!--{if $datainfo.status eq 2}--> checked<!--{/if}-->>&nbsp;&nbsp;<input type="radio" name="status" value="3" title="<!--{$lang.page.table.close}-->" <!--{if $datainfo.status eq 3}--> checked<!--{/if}-->>
            </div>
            </div>
                  
          <div class="layui-form-item layui-layout-admin">
            <div>
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn" type="button" id="submit" lay-submit lay-filter="submit"><!--{$lang.page.public.submit}--></button>
                <button type="reset" id="reset" class="layui-btn layui-btn-primary"><!--{$lang.page.public.reset}--></button>
                <button type="button" class="layui-btn layui-btn-primary" onClick="xadmin.close();" ><!--{$lang.page.table.back}--></button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
<script src="/static/lay/layui/layui.js"></script>
  <script type="text/javascript">
    layui.config({
     base: '/static/lay/' //静态资源所在路径
   }).extend({
     xadmin: 'lib/xadmin' //弹窗
   }).use(['jquery', 'layer','xadmin', 'form', 'element','layedit','laydate'], function(){
    var $ = layui.$ //引用jq
    var layer = layui.layer; //独立版的layer无需执行这一句
    var form = layui.form;
     form.render(null, 'component-form-group');
        var layedit = layui.layedit;
        layedit.set({
            uploadImage: {
                 url: '/content/common/editor_upload_img/'
                ,type: 'post' //默认post
            }
        });
        description=layedit.build('demo',{tool: [
            'strong' //加粗
            ,'italic' //斜体
            ,'underline' //下划线
            ,'del' //删除线
            ,'|' //分割线
            ,'left' //左对齐
            ,'center' //居中对齐
            ,'right' //右对齐
            ,'link' //超链接
            ,'unlink' //清除链接
            ,'face' //表情
            ,'image' //插入图片
            ,'code'
            ,'help' //帮助
        ]}); //建立编辑器

        layui.laydate.render({
          type: 'datetime'
          ,elem: '#timerange'
          ,range: ['#startDate', '#endDate']
        });
     /* 自定义验证规则 */
    form.verify({
      title: function(value){
        if(value.length < 1){
          return '<!--{$lang.page.table.name}--> <!--{$lang.page.public.nocontent}-->';
        }else if(value < 1){
          return '<!--{$lang.page.public.select}--> <!--{$lang.page.table.product}-->';
        }
      }
      ,double: function(value){
        if(/^\d+$/.test(value)==false && /^\d+\.\d+$/.test(value)==false)
        {
            return '<!--{$lang.page.public.paraerror}-->';
        }
      }
      ,description: function(value) {
          return layedit.sync(description);
        }
    });

    form.on('select(brickType)', function(data) {
          var proname = $(data.elem).find("option:selected").attr("data-proname");
          $('input[name="title"]').val(proname);
    });

    form.on('radio(brickType)', function(data){
        var p = data.value;
        if( p == 1 ){
            $('.showfk').hide();
            $('.yunying').show();
            
        }else if( p == 2 ){
            $('.showfk').show();
            $('.yunying').hide();
        }
        form.render();
    });

    form.on('submit(delall)', function (data) {
          if(data.field.run==1){
            layer.alert('<!--{$lang.page.public.conwarn}-->', {
                offset:'100px'
                , closeBtn: 1 // 是否显示关闭按钮
                , anim: 1 //动画类型
                , btn: ['<!--{$lang.page.table.confirm}-->', '<!--{$lang.page.table.cancel}-->'] //按钮
                , icon: 6 // icon
                , yes: function () {
                    $('#delall').attr("disabled",true);
                    $('#delall').addClass('layui-btn-disabled');
                    $.post('riskdel',data.field,function(res){
                        if(res.code == 200){
                            layer.msg(res.msg);
                            setTimeout(() => {
                                window.location.reload();
                                // xadmin.close();
                            }, 1000);
                        }else{
                          $('#delall').removeAttr("disabled");
                          $('#delall').removeClass('layui-btn-disabled');
                          layer.msg(res.msg);
                        }
                    })
                }
            });
          }else{
              $('#delall').attr("disabled",true);
              $('#delall').addClass('layui-btn-disabled');
              $.post('riskdel',data.field,function(res){
                  if(res.code == 200){
                      layer.msg(res.msg);
                      setTimeout(() => {
                          window.location.reload();
                          // xadmin.close();
                      }, 1000);
                  }else{
                      $('#delall').removeAttr("disabled");
                      $('#delall').removeClass('layui-btn-disabled');
                      layer.msg(res.msg);
                  }
            })
          }
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });
    
    form.on('submit(submit)', function (data) {
          $('#submit').attr("disabled",true);
          $('#submit').addClass('layui-btn-disabled');
              $.post('#',data.field,function(res){
                  if(res.code == 200){
                      layer.msg(res.msg);
                      setTimeout(() => {
                          window.parent.location.reload();
                          xadmin.close();
                      }, 1000);
                  }else{
                      $('#submit').removeAttr("disabled");
                      $('#submit').removeClass('layui-btn-disabled');
                      layer.msg(res.msg);
                  }
              })
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });
    //重置按钮，可以提交失败的时候再次提交
    $('#reset').click(function(){
        $('#submit').removeAttr("disabled");
        $('#submit').removeClass('layui-btn-disabled');
    });

    $('#checkuser').on('click', function(){
        var data = 'checkuser';
        layer.open({
          type: 2,
          title: '<!--{$lang.page.public.select}-->',
          offset: '50px', 
          closeBtn: 1, //要显示关闭按钮
          anim: 2,
          shadeClose: true, //开启遮罩
          // moveOut: true,
          area: ['1024px', '700px'],
          content: '/user/account/checklist/'
          ,resize:false
          ,maxmin: false //开启最大化最小化按钮
          ,success:function (layero, index) {
            var iframe = window['layui-layer-iframe'+index]; // 获取子页面的iframe
            iframe.child(data);// 向子页面的全局函数child传参
          }
        });
        window.ppp = function(value){
            if (value != "") {
                value = value.split("-")
                $('input[name="aid"]').val(value[0]); //将子页面传来的值赋值到指定输入框
                $('input[name="username"]').val(value[2]); //将子页面传来的值赋值到指定输入框
            }
        }
    })

    $('#checkoper').on('click', function(){
        var data = 'checkoper';
        layer.open({
          type: 2,
          title: '<!--{$lang.page.public.select}-->',
          offset: '50px', 
          closeBtn: 1, //要显示关闭按钮
          anim: 2,
          shadeClose: true, //开启遮罩
          // moveOut: true,
          area: ['1024px', '700px'],
          content: 'checklist'
          ,resize:false
          ,maxmin: false //开启最大化最小化按钮
          ,success:function (layero, index) {
            var iframe = window['layui-layer-iframe'+index]; // 获取子页面的iframe
            iframe.child(data);// 向子页面的全局函数child传参
          }
        });
        window.ppp = function(value){
            if (value != "") {
                value = value.split("-")
                $('input[name="relate"]').val(value[0]); //将子页面传来的值赋值到指定输入框
                $('input[name="conuts"]').val(value[1]); //将子页面传来的值赋值到指定输入框
                $('input[name="relatename"]').val(value[2]); //将子页面传来的值赋值到指定输入框
            }
        }
    })

  });

  </script>
</body>
</html>

